SpatialStream® Code Examples

Context Query

The GetQuery functional component is a useful general query tool that can construct context queries that return results relative to a specific location, or context point. This is important because it offers the option to incorporate location logic to your queries, resulting in more relevant results. Context query works by defining a context point (i.e. center of map) as the starting point of the query and returns results that are closest to the context point first, and radiating out thereafter.

This example constructs a Context Query on the Gas Station layer and sets the center of the screen as its spatial context (context point). Panning the map will reset the context. A red “X” will be placed at the context point and the 5 closest Gas Stations will be displayed in bright green.

The primary benefit of Context Query is its ability to return records from large datasets that are in your area of interest and that meet your attribute criteria. This makes querying large data sets more manageable and produces results that more accurately reflect the intent of the end-user.

GetQuery

var url = "GetQuery.aspx?";
url += "dataSource=ACCOUNT_FOLDER/IrvineGasStations";
url += "&maxRecords=5&minRecourds=5";
url += "&returnGeoType=3"; //centroid
url += "&cache=true";
url += "&contextPoint=POINT(" + map.getCenter().lng() + " " + map.getCenter().lat() + ")";


Run Sample   View Video   Back To Index